/*     */ package com.cr.business;
/*     */ 
/*     */ import com.cr.business.domain.CrDebtTransaction;
/*     */ import com.cr.business.domain.CrEvidenceInfo;
/*     */ import com.cr.business.service.ICrDebtTransactionService;
/*     */ import com.cr.business.service.ICrEvidenceInfoService;
/*     */ import com.cr.common.annotation.Log;
/*     */ import com.cr.common.core.controller.BaseController;
/*     */ import com.cr.common.core.domain.AjaxResult;
/*     */ import com.cr.common.core.page.TableDataInfo;
/*     */ import com.cr.common.enums.BusinessType;
/*     */ import com.cr.common.utils.poi.ExcelUtil;
/*     */ import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
/*     */ import java.util.Date;
/*     */ import java.util.List;
/*     */ import java.util.stream.Collectors;
/*     */ import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.ui.ModelMap;
/*     */ import org.springframework.web.bind.annotation.*;
/*     */
/*     */
/*     */
/*     */

/*     */
/*     */ @Controller
/*     */ @RequestMapping({"/business/transaction"})
/*     */ public class CrDebtTransactionController extends BaseController {
/*  40 */   private String prefix = "business/transaction";
/*     */   
/*     */   @Autowired
/*     */   private ICrDebtTransactionService crDebtTransactionService;
/*     */   
/*     */   @Autowired
/*     */   private ICrEvidenceInfoService evidenceInfoService;
/*     */   
/*     */   @RequiresPermissions({"business:transaction:view"})
/*     */   @GetMapping
/*     */   public String transaction() {
/*  51 */     return this.prefix + "/transaction";
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"business:transaction:list"})
/*     */   @PostMapping({"/list"})
/*     */   @ResponseBody
/*     */   public TableDataInfo list(CrDebtTransaction crDebtTransaction) {
/*  62 */     startPage();
/*  63 */     List<CrDebtTransaction> list = this.crDebtTransactionService.selectCrDebtTransactionList(crDebtTransaction);
/*  64 */     return getDataTable(list);
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"business:transaction:export"})
/*     */   @Log(title = "债权交易", businessType = BusinessType.EXPORT)
/*     */   @PostMapping({"/export"})
/*     */   @ResponseBody
/*     */   public AjaxResult export(CrDebtTransaction crDebtTransaction) {
/*  76 */     List<CrDebtTransaction> list = this.crDebtTransactionService.selectCrDebtTransactionList(crDebtTransaction);
/*  77 */     ExcelUtil<CrDebtTransaction> util = new ExcelUtil(CrDebtTransaction.class);
/*  78 */     return util.exportExcel(list, "债权交易数据");
/*     */   }
/*     */   
/*     */   @GetMapping({"/add"})
/*     */   public String add() {
/*  87 */     return this.prefix + "/add";
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"business:transaction:add"})
/*     */   @Log(title = "债权交易", businessType = BusinessType.INSERT)
/*     */   @PostMapping({"/add"})
/*     */   @ResponseBody
/*     */   public AjaxResult addSave(@RequestBody CrDebtTransaction crDebtTransaction) throws InvocationTargetException, IllegalAccessException {
/*  99 */     int i = this.crDebtTransactionService.insertCrDebtTransaction(crDebtTransaction);
/* 100 */     if (i > 0 &&
/* 101 */       CollectionUtils.isNotEmpty(crDebtTransaction.getDebtorList())) {
/* 102 */       List<CrDebtTransaction.AddDebtor> fileList = crDebtTransaction.getDebtorList();
/* 104 */       for (CrDebtTransaction.AddDebtor debtor:fileList) {
/* 105 */           CrEvidenceInfo info = new CrEvidenceInfo();
                    BeanUtils.copyProperties(info,debtor);
/* 106 */           info.setClueId(crDebtTransaction.getTransactionId());
/* 110 */           this.evidenceInfoService.insertCrEvidenceInfo(info);
/*     */       }
             }
/* 114 */     return toAjax(i);
/*     */   }
/*     */   
/*     */   @GetMapping({"/edit/{transactionId}"})
/*     */   public String edit(@PathVariable("transactionId") Long transactionId, ModelMap mmap) {
/* 123 */     CrDebtTransaction crDebtTransaction = this.crDebtTransactionService.selectCrDebtTransactionByTransactionId(transactionId);
/* 124 */     //CrEvidenceInfo evidenceInfo = new CrEvidenceInfo();
/* 125 */     //evidenceInfo.setClueId(crDebtTransaction.getTransactionId());
/* 126 */     //evidenceInfo.setType(Integer.valueOf(1));
/* 127 */     //List<CrEvidenceInfo> infoList = this.evidenceInfoService.selectCrEvidenceInfoList(evidenceInfo);
/* 128 */     //if (infoList.size() > 0) {
/* 129 */       //String fileUrl = String.join(",", (Iterable<? extends CharSequence>)infoList.stream().map(v -> v.getImage()).collect(Collectors.toList()));
/* 130 */       //crDebtTransaction.setFileUrl(fileUrl);
/*     */     //}
/* 132 */     //mmap.put("fileList", infoList);
/* 134 */     mmap.put("crDebtTransaction", crDebtTransaction);
/* 135 */     return this.prefix + "/edit";
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"business:transaction:edit"})
/*     */   @Log(title = "债权交易", businessType = BusinessType.UPDATE)
/*     */   @PostMapping({"/edit"})
/*     */   @ResponseBody
/*     */   public AjaxResult editSave(CrDebtTransaction crDebtTransaction) {
/* 147 */     int i = this.crDebtTransactionService.updateCrDebtTransaction(crDebtTransaction);
///* 148 */     if (i > 0 &&
///* 149 */       StringUtils.isNotEmpty(crDebtTransaction.getFileUrl())) {
///* 151 */       CrEvidenceInfo evidenceInfo = new CrEvidenceInfo();
///* 152 */       evidenceInfo.setClueId(crDebtTransaction.getTransactionId());
///* 153 */       evidenceInfo.setType(Integer.valueOf(1));
///* 154 */       List<CrEvidenceInfo> infoList = this.evidenceInfoService.selectCrEvidenceInfoList(evidenceInfo);
///* 155 */       if (infoList.size() > 0) {
///* 156 */         List<String> ids = (List<String>)infoList.stream().map(v -> v.getEvidenceId().toString()).collect(Collectors.toList());
///* 157 */         this.evidenceInfoService.deleteCrEvidenceInfoByEvidenceIds(String.join(",", (Iterable)ids));
///*     */       }
///* 159 */       List<String> fileList = Arrays.asList(crDebtTransaction.getFileUrl().split(","));
///* 160 */       List<String> fileName = Arrays.asList(crDebtTransaction.getFileName().split(","));
///* 161 */       for (int k = 0; k < fileList.size(); k++) {
///* 162 */         CrEvidenceInfo info = new CrEvidenceInfo();
///* 163 */         info.setClueId(crDebtTransaction.getTransactionId());
///* 164 */         info.setImage(fileList.get(k));
///* 165 */         info.setType(Integer.valueOf(1));
///* 166 */         info.setName(fileName.get(k));
///* 167 */         this.evidenceInfoService.insertCrEvidenceInfo(info);
///*     */       }
///*     */     }
/* 171 */     return toAjax(i);
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"business:transaction:remove"})
/*     */   @Log(title = "债权交易", businessType = BusinessType.DELETE)
/*     */   @PostMapping({"/remove"})
/*     */   @ResponseBody
/*     */   public AjaxResult remove(String ids) {
/* 183 */     return toAjax(this.crDebtTransactionService.deleteCrDebtTransactionByTransactionIds(ids));
/*     */   }
/*     */   
/*     */   @GetMapping({"/audit/{transactionId}"})
/*     */   public String audit(@PathVariable("transactionId") Long transactionId, ModelMap mmap) {
/* 190 */     CrDebtTransaction crDebtTransaction = this.crDebtTransactionService.selectCrDebtTransactionByTransactionId(transactionId);
/* 191 */     mmap.put("crDebtTransaction", crDebtTransaction);
/* 192 */     return this.prefix + "/audit";
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"business:user:edit"})
/*     */   @Log(title = "债权交易", businessType = BusinessType.UPDATE)
/*     */   @PostMapping({"/audit"})
/*     */   @ResponseBody
/*     */   public AjaxResult auditSave(CrDebtTransaction crDebtTransaction) {
/* 203 */     crDebtTransaction.setApprovalTime(new Date());
/* 204 */     return toAjax(this.crDebtTransactionService.updateCrDebtTransaction(crDebtTransaction));
/*     */   }
/*     */   
/*     */   @GetMapping({"/info/{transactionId}"})
/*     */   public String info(@PathVariable("transactionId") Long transactionId, ModelMap mmap) {
/* 211 */     CrDebtTransaction crDebtTransaction = this.crDebtTransactionService.selectCrDebtTransactionByTransactionId(transactionId);
/* 213 */     CrEvidenceInfo evidenceInfo = new CrEvidenceInfo();
/* 214 */     evidenceInfo.setClueId(crDebtTransaction.getTransactionId());
/* 216 */     List<CrEvidenceInfo> infoList = this.evidenceInfoService.selectCrEvidenceInfoList(evidenceInfo);
/* 221 */     mmap.put("personList", infoList);
/* 222 */     mmap.put("crDebtTransaction", crDebtTransaction);
/* 223 */     return this.prefix + "/info";
/*     */   }
/*     */   
/*     */   @GetMapping({"/pay/{transactionId}"})
/*     */   public String pay(@PathVariable("transactionId") Long transactionId, ModelMap mmap) {
/* 231 */     CrDebtTransaction crDebtTransaction = this.crDebtTransactionService.selectCrDebtTransactionByTransactionId(transactionId);
/* 232 */     mmap.put("crDebtTransaction", crDebtTransaction);
/* 233 */     return this.prefix + "/pay";
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"business:user:edit"})
/*     */   @Log(title = "债权交易", businessType = BusinessType.UPDATE)
/*     */   @PostMapping({"/pay"})
/*     */   @ResponseBody
/*     */   public AjaxResult paySave(CrDebtTransaction crDebtTransaction) {
/* 244 */     crDebtTransaction.setPayTime(new Date());
/* 245 */     return toAjax(this.crDebtTransactionService.updateCrDebtTransaction(crDebtTransaction));
/*     */   }
/*     */ }


/* Location:              D:\tmp\creditorRights-admin\BOOT-INF\classes\com.zip!\com\cr\business\CrDebtTransactionController.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */